package 每日一题;

import java.util.Arrays;

/**
 * @author 会玩的洋洋
 * https://leetcode.cn/problems/maximum-number-of-consecutive-values-you-can-make/
 */
public class _1798_你能构造出连续值的最大数目 {
    /**
     * 执行用时：17ms，内存消耗：48.8MB
     * @param coins
     * @return
     */
    public int getMaximumConsecutive(int[] coins) {
        int res = 1;
        Arrays.sort(coins);

        for (int coin : coins) {
            if (coin > res) {
                break;
            }
            res += coin;
        }
        return res;
    }
}
